<!DOCTYPE html>
<meta charset="utf-8">
<title>Check caret position inside empty cell</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<style>
  table {
    font-size: 2em;
  }
  td {
    vertical-align: top;
    padding: 5px;
  }
  #emptycell {
    width: 50%;
  }
</style>

<p>Test passes if the caret in the empty cell is inside the cell itself (that means it's vertically aligned with the reference text).</p>

<table border="1" contenteditable>
  <td>Reference text</td>
  <td id="emptycell"></td>
</table>

<script>
  var selection = window.getSelection();
  var emptycell = document.getElementById("emptycell");
  selection.collapse(emptycell, 0);
</script>
